
const state ={
    myRouter:[
        {path:'/Main/Home',iconName:'el-icon-house',name:'首页'}
    ]
};
const actions={
    routerFun({commit},obj){
       commit('pushRouter',obj)
    }
};
const mutations ={
    pushRouter(state,obj){
        //let arr = obj.path.split('/')
        // if(obj.name !== '首页'){
        //     if(state.myRouter.length <=1){
        //         state.myRouter.push(obj)
        //     }else if(!arr[3]){
        //         state.myRouter.splice(1,2,obj)
        //     }else if( state.myRouter.length <3 && arr[3]){
        //         state.myRouter.push(obj)
        //     }else if(state.myRouter.length === 3){
        //         state.myRouter.splice(2,1,obj)
        //     }
        // }else {
        //     state.myRouter.splice(1,2)
        // }
        if(obj.name !== '首页'){
            if(state.myRouter.length <=1){
                state.myRouter.push(obj)
            }else if(state.myRouter.length ===2){
                state.myRouter.splice(1,1,obj)
            }
        }else {
            state.myRouter.splice(1,1)
        }
        let myRouter = JSON.stringify(state.myRouter)
        sessionStorage.setItem('myRouter',myRouter)
    }
};
const getters ={

};
export default{
    state,
    actions,
    mutations,
    getters
}